<template>
  <div>
    <div class="cmt_new">
      <div class="cmt_item">
        <div class="cmt_info">
          <img :src="$axios.defaults.baseURL+commentData.account.defaultAvatar" />
          {{commentData.account.nickname}}
          <i>{{commentData.created_at |itemDate}}</i>
          <span>{{commentData.level}}</span>
        </div>
        <div class="cmt_content">
          <PostItemparent
            :parentData="commentData.parent"
            v-if="commentData.parent"
            @parentCallReply="parentCallReply"
          />

          <div class="cmt_new" @mouseenter="isReply=true" @mouseleave="isReply=false">
            <p class="cmt_message">{{commentData.content}}</p>
            <div v-if="commentData.pics.length!=0" class="cmt_pics">
              <div class="cmt_pic" v-for="(item,index) in commentData.pics" :key="index">
                <!-- <el-image
                  style="width: 100px; height: 100px"
                  :src="$axios.defaults.baseURL+item.url"
                  :preview-src-list="$axios.defaults.baseURL+item.url"
                ></el-image>-->
                <img :src="$axios.defaults.baseURL+item.url" alt />
              </div>
            </div>
            <div class="cmt_ctrl">
              <a href="javascript:;" v-show="isReply" @click="handleClick">回复</a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import moment from "moment";

export default {
  props: ["commentData"],
  data() {
    return {
      isReply: false
    };
  },

  methods: {
    handleClick() {
      // console.log("点击触发回复");
      this.$emit("callReply", this.commentData);
    },
    parentCallReply(parentData) {
      this.$emit("callReply", parentData);
    }
  },
  filters: {
    itemDate(e) {
      return moment(e).format("YYYY-MM-DD HH:mm");
    }
  }
};
</script>


<style lang="less" scoped>
.cmt_item {
  i {
    color: #999;
  }
  border-bottom: 1px dashed #ddd;
  padding: 20px 20px 5px;
  .cmt_info {
    margin-bottom: 10px;
    font-size: 12px;
    color: #666;
    img {
      width: 16px;
      height: 16px;
      border-radius: 50%;
    }
    span {
      float: right;
    }
  }
  .cmt_content {
    padding: 0 0 0 30px;
    .cmt_message {
      margin-top: 10px;
    }
    .cmt_pics {
      display: flex;
      .cmt_pic {
        width: 80px;
        height: 80px;
        border-radius: 6px;
        overflow: hidden;
        margin-right: 5px;
        margin-top: 10px;
        padding: 5px;
        border: 1px dashed #ddd;
        img {
          display: block;
          width: 100%;
          height: 100%;
          object-fit: cover;
          cursor: pointer;
        }
      }
    }
    .cmt_ctrl {
      height: 20px;
      height: 20px;
      line-height: 20px;
      font-size: 12px;
      text-align: right;
      color: #1e50a2;
      a {
        text-decoration: none;
        color: inherit;
      }
    }
    .cmt_floor {
      background: #f9f9f9;
      border: 1px solid #ddd;
      padding: 2px;
      .cmt_content {
        padding: 5px 10px 0;
      }
    }
  }
}
</style>